package ji.sky.commonintents;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btn_alarm_clock; //闹钟
    private Button btn_phone_call;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //widget组件初始化
        init_widgets();
    }

    protected void init_widgets(){
        btn_alarm_clock = findViewById(R.id.btn_alarm_clock);
        btn_phone_call = findViewById(R.id.btn_phone_call);

        btn_alarm_clock.setOnClickListener(this);
        btn_phone_call.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        if(view.getId() == R.id.btn_alarm_clock){
            //闹钟事件
            Intent intent = new Intent(MainActivity.this, AlarmClockActivity.class);
            startActivity(intent);
        }
        if(view.getId() == R.id.btn_phone_call){
            Intent intent = new Intent();
            intent.setAction("ji.sky.commonintents.PHONE_CALL");
            startActivity(intent);

        }
    }
}